package com.wuzheng.wisgo.sanitation.cloud.controller.vehicle;


import com.wuzheng.wisgo.sanitation.cloud.repository.entity.vehicle.BaVehicleType;
import com.wuzheng.wisgo.sanitation.cloud.model.vehicle.BaVehicleTypeCriteria;
import com.wuzheng.wisgo.sanitation.cloud.service.vehicle.VehicleTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.wuzheng.wisgo.sanitation.framework.core.protocol.Result;

import java.util.List;


import org.springframework.web.bind.annotation.RestController;
import com.wuzheng.wisgo.sanitation.framework.base.controller.BaseController;

/**
 * @author：sp
 * @date：Created in 2019-10-09
 * @description：车辆类型控制器
 * @modified By：
 * @version: 1.0
 */
@RestController
@RequestMapping("/vehicleType")
@Api(value = "VehicleTypeCtrl", tags = "车辆类型接口")
public class VehicleTypeCtrl extends BaseController {

    @Autowired
    private VehicleTypeService vehicleTypeService;

    /**
     * 获取车辆类型列表
     */
    @PostMapping(value = "/fetchList")
    @ApiOperation(value = "获取车辆类型列表")
    public Result<List<BaVehicleType>> list(@RequestBody BaVehicleTypeCriteria baVehicleTypeCriteria)
    {
        return this.success(vehicleTypeService.selectPage(baVehicleTypeCriteria));
    }

    /**
     * 新增车辆类型
     */
    @PostMapping(value = "/add")
    @ApiOperation(value = "新增车辆类型")
    public Result<String> add(BaVehicleType baVehicleType) {
        vehicleTypeService.insert(baVehicleType);
        return this.success("新增成功");
    }

    /**
     * 删除车辆类型
     */
    @PostMapping(value = "/delete/{id}")
    @ApiOperation(value = "删除车辆类型")
    public Result<String> delete(@PathVariable("id") Long id) {
        vehicleTypeService.deleteById(id);
        return this.success("删除成功");
    }

    /**
     * 修改车辆类型
     */
    @PostMapping(value = "/update")
    @ApiOperation(value = "修改车辆类型")
    public Result<String> update(BaVehicleType baVehicleType) {
        vehicleTypeService.updateById(baVehicleType);
        return this.success("修改成功");
    }

    /**
     * 获取车辆类型
     */
    @GetMapping(value = "/get/{id}")
    @ApiOperation(value = "获取车辆类型")
    public Result<BaVehicleType> get(@PathVariable("id") Long id) {
        return this.success(vehicleTypeService.selectById(id));
    }
}

